﻿using System;
using YJKCodeBase.YJKElement;
using YJKCodeBase.Math;

namespace YJKCodeBase.Geometry
{
	public class HYPointXYZ : HYCoreElement
	{
		public double X
		{
			get
			{
				return this.m_dX;
			}
			set
			{
				this.m_dX = value;
			}
		}

		public double Y
		{
			get
			{
				return this.m_dY;
			}
			set
			{
				this.m_dY = value;
			}
		}

		public double Z
		{
			get
			{
				return this.m_dZ;
			}
			set
			{
				this.m_dZ = value;
			}
		}

		public HYPointXYZ(double inputX, double inputY, double inputZ = 0.0, bool ifRealValue = false)
		{
			if (!ifRealValue)
			{
                this.X = System.Math.Round(inputX, 3);
                this.Y = System.Math.Round(inputY, 3);
                this.Z = System.Math.Round(inputZ, 3);
				return;
			}
			this.X = inputX;
			this.Y = inputY;
			this.Z = inputZ;
		}

		public double DistanceTo(HYPointXYZ input)
		{
			double num = 0.0;
            num += System.Math.Pow(input.X - this.X, 2.0);
            num += System.Math.Pow(input.Y - this.Y, 2.0);
            num += System.Math.Pow(input.Z - this.Z, 2.0);
            return System.Math.Pow(num, 0.5);
		}

		public bool IfAlMostEqual(HYPointXYZ input, bool if2d = false, double eps = 1E-09)
		{
			if (input == null)
			{
				return false;
			}
			if (if2d)
			{
				return MathUtility.IsEqual(this.X, input.X, eps) && MathUtility.IsEqual(this.Y, input.Y, eps);
			}
			return MathUtility.IsEqual(this.X, input.X, eps) && MathUtility.IsEqual(this.Y, input.Y, eps) && MathUtility.IsEqual(this.Z, input.Z, eps);
		}

		public const int m_nUsePrecisionDegree = 3;

		private double m_dX;

		private double m_dY;

		private double m_dZ;
	}
}
